export default {
    login: (config) => {
        // 数据处理返回
        // console.log(11, config);
        // 获取前端传过来的参数
        let { name, pwd } = JSON.parse(config.body)
        // console.log(name, pwd);
        let token = '' //后台返回token 一般由前端传过来的用户名和密码以及时间戳经过算法生成
        let role = ''
        if (name == 'admin' && pwd == '123456') {
            token = 'admin----token----123',
                role = '管理员'
        } else if (name == 'user' && pwd == '123456') {
            token = 'user----token----456'
            role = '普通用户'
        } else if (name == '小月月' && pwd == '123456') {
            token = 'user----token----789'
            role = '普通用户'
        } else {
            return {
                code: 500,
                msg: "账户不存在",
                data: {}
            }
        }

        return {
            code: 200,
            msg: "登录成功",
            data: {
                token: token,
                role: role
            }
        }
    },
    getPress: (config) => {
        let { role } = JSON.parse(config.body)
        if (role == '管理员') {
            return {
                code: 200,
                msg: "请求成功",
                data: [
                    {
                        path: "shenpi",
                        name: 'Shenpi',  //componet
                        meta: {
                            title: '审批管理',
                            icon: 'el-icon-bangzhu'
                        }
                    },
                    {
                        path: 'qingjia', //请假审批
                        meta: {
                            title: '请假审批',
                            icon: 'el-icon-bangzhu'
                        },
                        name: 'Qingjia'  //componet
                    },
                    {
                        path: 'woqingjia', //我要请假
                        meta: {
                            title: '我要请假',
                            icon: 'el-icon-bangzhu'
                        },
                        name: 'Woqingjia'  //componet
                    }
                ]
            }
        } else if (role == '普通用户') {
            return {
                code: 200,
                msg: "请求成功",
                data: [{
                    path: 'woqingjia', //我要请假
                    meta: {
                        title: '我要请假',
                        icon: 'el-icon-bangzhu'
                    },
                    name: 'Woqingjia'  //componet
                }]
            }
        }
    }
}